home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libcompress-zlib-perl / examples / filtinf < prev    next >
Encoding:
Text File  |  2008-11-08  |  470 b   |  29 lines

  1. #!/usr/bin/perl
  2.  
  3. use strict ;
  4. use warnings ;
  5.  
  6. use Compress::Zlib ;
  7.  
  8. my $x = inflateInit()
  9.    or die "Cannot create a inflation stream\n" ;
  10.  
  11. my $input = '' ;
  12. binmode STDIN;
  13. binmode STDOUT;
  14.  
  15. my ($output, $status) ;
  16. while (read(STDIN, $input, 4096))
  17. {
  18.     ($output, $status) = $x->inflate(\$input) ;
  19.  
  20.     print $output 
  21.         if $status == Z_OK or $status == Z_STREAM_END ;
  22.  
  23.     last if $status != Z_OK ;
  24. }
  25.  
  26. die "inflation failed\n"
  27.     unless $status == Z_STREAM_END ;
  28.  
  29.